<% layout('/layouts/default.html', {title: '任务接收', libs: ['dataGrid']}){ %>
<div class="main-content">
    <div class="box box-main">

        <div class="box-body">
            <#form:form id="searchForm" model="${queryThreePage}" action="${ctx}/home/supIndex/queryThreePage?limit=0&taskYear=${queryThreePage}" method="post" class="form-inline"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <div style="text-align: right">
                <div class="form-group">
                    <label class="control-label">${text('督办字号')}：</label>
                    <div class="control-inline width-160">
                        <#form:input path="messageNumber" maxlength="50" class="form-control width-160" placeholder="请输入督办字号"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="control-inline width-160">
                        <#form:input path="taskTitle" maxlength="200" class="form-control width-160" placeholder="请输入任务标题或内容"/>
                    </div>
                </div>
                <div class="form-group" >
                    <button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
                    <button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
                </div>
            </div>
        </#form:form>
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>
</div>
</div>
<% } %>
<script>
    function getFeedbackCount1(feedbackCount, feedbackCount1) {
        let tempStr = '';
        if (feedbackCount > 0 && feedbackCount1 > 0) {
            tempStr = ("逾期未反馈&nbsp;"+feedbackCount+"&nbsp;次"+",逾期反馈&nbsp;"+feedbackCount1+"&nbsp;次")+'</a>';
        }
        if (feedbackCount > 0 && feedbackCount1 == 0) {
            tempStr = ("逾期未反馈&nbsp;"+feedbackCount+"&nbsp;次")+'</a>';
        }
        if (feedbackCount == 0 && feedbackCount1 > 0) {
            tempStr = ("逾期反馈&nbsp;"+feedbackCount1+"&nbsp;次")+'</a>';
        }
        return tempStr;
    }

    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        sortableColumn: false, // 列表不允许排序
        // showCheckbox: true,
        columnModel: [
            {header: '${text("主键")}', name: 'taskId', index: 'a.taskId', width: 150, align: "left", hidden: true},
            {header:'${text("action主键")}', name:'id', width:150, align:"left", hidden:true},
            {header: '${text("督办字号")}', name: 'messageNumber', index: 'a.message_number', width: 150, align: "left"},
            {header: '${text("任务标题")}', name: 'taskTitle', index: 'a.task_title', width: 150, align: "left"},
            {header: '${text("任务类型")}', name: 'taskTypeName', index: 'a.task_type_code', width: 150, align: "left"},
            {header: '${text("牵头责任单位")}', name: 'leaderOrgName', index: 'a.leader_org_name', width: 150, align: "left"},
            {header: '${text("任务内容")}', name: 'taskContent', index: 'a.task_content', width: 150, align: "left"},
            { header: '${text("逾期情况")}', name: 'feedbackCount', index: 'a.feedback_count', width: 200, align: "left", formatter: function(val, obj, row, act){
                    return '<a style="color: #ff8b19" href="${ctx}/audit/taskReceive/taskReceiveFive?isNewRecord=false&id='+row.id+ '&taskId=' + row.taskId + '" class="btnList" data-title="${text("督办任务信息")}">' + getFeedbackCount1(val, row.feedbackCount1);
                }
            },
            {header:'${text("操作")}', name:'actions', width:100,align:"center", formatter: function(val, obj, row, act){
                    var actions = [];
                    actions.push('<a style="cursor:pointer;" onclick=cuiban("' + row.id + '") class="btn btn-primary btn-xs" title="${text("催办")}" ><span>催办</span></a>&nbsp;');
                    return actions.join('');
                }}

    ],
    // 加载成功后执行事件
    ajaxSuccess: function(data){

    }
    // ,onSelectRow: function (id, isSelect, event) {
    //         let obj = $('#dataGrid').dataGrid('getRowData', id);
    //         js.addTabPage(null, "任务详情", "${ctx}/audit/taskReceive/taskReceiveFive?isNewRecord=false&id=" + obj.id + "&taskId=" + obj.taskId, true,true);
    //     }
    });
    function cz(){
        searchForm.reset();
        $('#dataGrid').dataGrid('reloadGrid');
    }

    function cuiban(id){
        js.loading();
        js.layer.open({
            type: 2,
            title: ['催办'],
            area: ['800px', '400px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/home/supIndex/cuibanPage?id="+id,
            btn1: function (index, layero) {
            },
            success: function (data) {
                js.closeLoading(0, true);
            },
            end:function () {

            }
        });
        // js.loading("正在催办...");
        // $.ajax({
        //     url: "${ctx}/home/supIndex/cuiban",
        //     type: "post",
        //     data: {
        //         "id":id
        //     },
        //     success: function(data){
        //         js.closeLoading(0, true);
        //         js.showMessage(data.message);
        //     },
        //     error: function(data){
        //         js.closeLoading(0, true);
        //         js.showErrorMessage(data.responseJSON.message+"，请联系管理员");
        //     }
        // });
    }
    function clickLine(row){
        js.addTabPage(null, "任务详情", "${ctx}/audit/taskReceive/taskReceiveFive?isNewRecord=false&id=" + row.id + "&taskId=" + row.taskId, true,true);
    }

</script>